package thread;

/**
 * Created with IntelliJ IDEA.
 * Description: 单例模式例-例1饿汉方式
 * User: 王圆豪
 * Date: 2025-04-29
 * Time: 23:31
 */
class Singleton {
    private static Singleton instance = new Singleton();

    public static Singleton getInstance() {
        return instance;
    }

    private Singleton(){}
}
public class Demo25 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1 == s2);
    }
}
